package insight.app.config.security;

import javax.sql.DataSource;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
import org.springframework.security.config.annotation.authentication.builders.AuthenticationManagerBuilder;
import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity;
import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter;

@Configuration
@EnableWebSecurity
@ComponentScan(basePackages = "insight.app.config")
public class SecurityConfig extends WebSecurityConfigurerAdapter {
	@Autowired
	public DataSource dataSource;

	@Autowired
	public void configureGlobal(AuthenticationManagerBuilder auth)
			throws Exception {

		auth.inMemoryAuthentication().withUser("nsbassi").password("a")
				.roles("USER", "MANAGER", "ADMIN");

		// auth.jdbcAuthentication().dataSource(dataSource)
		// .usersByUsernameQuery("select username,password,enabled from users where username = ?")
		// .authoritiesByUsernameQuery("select username,authority from authorities where username = ?");
	}
}